package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsListDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 11:08
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto) {

        return wmNewsService.pageList(reqDto);
    }

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto newsDto) {
        return wmNewsService.submit(newsDto);
    }

    /**
     * 查询所有文章列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public PageResponseResult listVo(@RequestBody NewsListDto dto) {
        return wmNewsService.listVo(dto);
    }

    /**
     * 根据id查询文章详情和作者名字
     *
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult getOneById(@PathVariable("id") Long id) {
        return wmNewsService.getOneById(id);
    }

    /**
     * 审核失败
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsListDto dto){
        return wmNewsService.authAudit(dto);
    }

    /**
     * 审核成功
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsListDto dto){
        return wmNewsService.authAudit(dto);
    }
}